<?php get_instance()->view('common/header');?>
<div class="page-container home">
    <?php get_instance()->view('common/sidebar');?>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <h3 class="page-title"> <?php echo $title.' - 【时间：'.$startTime.' 至 '.$endTime.', 销售总额：'.$info['reality_amount'].'】' ?> </h3>
                    <ul class="page-breadcrumb breadcrumb">
                        <li class="btn-group"><a  href="<?php echo getUrl('statistics/operate')?>" class="btn default"><i class="fa fa-chevron-left"></i> 返回</a> </li>
                        <li><i class="fa fa-home"></i><a href="javascript:void(0);">销售统计<i class="fa fa-angle-right"></i></a></li>
                        <li><a href="javascript:void(0);"><?php echo $title ?> </a></li>
                    </ul>
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>
            </div>
            <!--开始-->

            <div class="row">
                <div class="col-md-12">
                    <div class="portlet">
                        <div class="portlet-body">
                            <ul class="nav nav-tabs" role="tablist">
                                <li role="presentation" class="active">
                                    <a href="#date" aria-controls="date" role="tab" data-toggle="tab"><i class="fa fa-list"></i>订单列表</a>
                                </li>
                                <li role="presentation">
                                    <a href="#merchant" aria-controls="merchant" role="tab" data-toggle="tab"><i class="fa fa-list"></i>售后列表</a>
                                </li>
                            </ul>
                            <div class="tab-content">
                                <div role="tabpanel" class="tab-pane active" id="date">
                                    <div class="panel panel-default">
                                        <div class="panel-body">
                                            <div class="table-container">
                                                <div class="table-actions-wrapper"> <span> </span>
                                                    <?php if(adminAuthority('sell-saleExport', 'statistics')):?>
                                                        <a class="btn btn-sm blue add export" href="javascript:;"><i class="fa fa-download"></i> 导出</a>
                                                    <?php endif;?>
                                                </div>
                                                <table class="table table-bordered table-hover scoll-title" id="datatable">
                                                    <thead>
                                                    <tr role="row" class="heading">
                                                        <th sort="false">编号</th>
                                                        <th sort="false">商家</th>
                                                        <th sort="false">会员</th>
                                                        <th sort="false">消费模式</th>
                                                        <th sort="false">支付方式</th>
                                                        <th sort="false">下单时间</th>
                                                        <th sort="false">接单时间</th>
                                                        <th sort="false">订单总额</th>
                                                        <th sort="false">订单优惠</th>
                                                        <th sort="false">退差价</th>
                                                        <th sort="false">实付金额</th>
                                                        <th width="100px" sort="false">状态</th>
                                                        <th width="100px" sort="false">操作</th>
                                                    </tr>
                                                    <tr>
                                                        <th><input class="form-control form-filter input-sm" name="orderCode" type="text"></th>
                                                        <th></th>
                                                        <th><input class="form-control form-filter input-sm" name="consumer" placeholder="" type="text"></th>
                                                        <th>
                                                            <select name="expenseType" class="form-control form-filter input-sm">
                                                                <option value="" selected="selected">所有</option>
                                                                <?php foreach ($expense_type as $ke => $e):?>
                                                                    <option value="<?php echo $ke;?>"><?php echo $e;?></option>
                                                                <?php endforeach;?>
                                                            </select>
                                                        </th>
                                                        <th>
                                                            <select name="payType" class="form-control form-filter input-sm">
                                                                <option value="" selected="selected">所有</option>
                                                                <?php foreach ($pay_type as $k => $v):?>
                                                                    <option value="<?php echo $k;?>"><?php echo $v;?></option>
                                                                <?php endforeach;?>
                                                            </select>
                                                        </th>
                                                        <th>
                                                            <div class="margin-bottom-5">
                                                                <input class="form-control form-filter input-sm" name="add_time_from" dp placeholder="从" type="text">
                                                            </div>
                                                            <input class="form-control form-filter input-sm" name="add_time_to" dp placeholder="到" type="text" ></th>
                                                        </th>
                                                        <th>
                                                            <div class="margin-bottom-5">
                                                                <input class="form-control form-filter input-sm" name="take_time_from" dp placeholder="从" type="text" value="<?php echo $startTime ?>">
                                                            </div>
                                                            <input class="form-control form-filter input-sm" name="take_time_to" dp placeholder="到" type="text" value="<?php echo $endTime ?>"></th>
                                                        </th>
                                                        <th>
                                                            <div class="margin-bottom-5">
                                                                <input class="form-control form-filter input-sm" name="amount_from" placeholder="大于等于" type="text">
                                                            </div>
                                                            <input class="form-control form-filter input-sm" name="amount_to" placeholder="小于等于" type="text" ></th>
                                                        </th>
                                                        <th>
                                                            <div class="margin-bottom-5">
                                                                <input class="form-control form-filter input-sm" name="discount_amount_from" placeholder="大于等于" type="text">
                                                            </div>
                                                            <input class="form-control form-filter input-sm" name="discount_amount_to" placeholder="小于等于" type="text" ></th>
                                                        </th>
                                                        <th></th>
                                                        <th>
                                                            <div class="margin-bottom-5">
                                                                <input class="form-control form-filter input-sm" name="reality_amount_from" placeholder="大于等于" type="text">
                                                            </div>
                                                            <input class="form-control form-filter input-sm" name="reality_amount_to" placeholder="小于等于" type="text" ></th>
                                                        </th>
                                                        <th>
                                                            <select name="orderStatus" class="form-control form-filter input-sm">
                                                                <option value="" selected="selected">所有</option>
                                                                <?php foreach ($status as $k => $v):?>
                                                                    <option value="<?php echo $k;?>"><?php echo $v;?></option>
                                                                <?php endforeach;?>
                                                            </select>
                                                        </th>
                                                        <th>
                                                            <div class="btn-group">
                                                                <a class="btn btn-xs filter-submit btn-default"><i class="fa fa-search"></i> 搜索</a>
                                                                <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                                <ul role="menu" class="dropdown-menu pull-right">
                                                                    <li><a href="javascript:void(0);" class="filter-cancel">重置</a></li>
                                                                </ul>
                                                            </div>
                                                        </th>
                                                    </tr>
                                                    </thead>
                                                    <tbody></tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div role="tabpanel" class="tab-pane" id="merchant">
                                    <div class="panel panel-default">
                                        <div class="panel-body">
                                            <div class="table-container">
                                                <div class="table-actions-wrapper"> <span> </span>
                                                    <?php if(adminAuthority('service-export', 'order')):?>
                                                        <a class="btn btn-sm blue add export" href="javascript:;"><i class="fa fa-download"></i> 导出</a>
                                                    <?php endif;?>
                                                </div>
                                                <table class="table table-bordered table-hover" id="datatable_after">
                                                    <thead>
                                                    <tr role="row" class="heading">
                                                        <th width="10%">售后单号</th>
                                                        <th width="10%">订单号</th>
                                                        <th width="12%">商家</th>
                                                        <th width="15%">退款商品</th>
                                                        <th width="15%">退款原因</th>
                                                        <th width="8%">退款金额 </th>
                                                        <th width="10%">完成时间</th>
                                                        <th width="10%">状态</th>
                                                        <th width="10%">操作</th>
                                                    </tr>
                                                    <tr>
                                                        <th><input class="form-control form-filter input-sm" name="serviceCode" type="text"></th>
                                                        <th><input class="form-control form-filter input-sm" name="orCode" placeholder="" type="text"></th>
                                                        <th><input class="form-control form-filter input-sm" name="serviceMerchant" placeholder="" type="text"></th>
                                                        <th><input class="form-control form-filter input-sm" name="productName" placeholder="" type="text"></th>
                                                        <th></th>
                                                        <th></th>
                                                        <th>
                                                            <div class="margin-bottom-5">
                                                                <input class="form-control form-filter input-sm" name="service_complete_time_from" dp placeholder="从" type="text" value="<?php echo $startTime ?>">
                                                            </div>
                                                            <input class="form-control form-filter input-sm" name="service_complete_time_to" dp placeholder="到" type="text" value="<?php echo $endTime ?>"></th>
                                                        </th>
                                                        <th>
                                                            <select name="serviceType" class="form-control form-filter input-sm">
                                                                <option value="" selected="selected">所有</option>
                                                                <?php foreach ($serviceType as $k => $v):?>
                                                                    <option value="<?php echo $k;?>"><?php echo $v;?></option>
                                                                <?php endforeach;?>
                                                            </select>
                                                        </th>
                                                        <th>
                                                            <div class="btn-group">
                                                                <a class="btn btn-xs filter-submit btn-default"><i class="fa fa-search"></i> 搜索</a>
                                                                <button data-toggle="dropdown" class="btn btn-default dropdown-toggle btn-xs" type="button"><i class="fa fa-angle-down"></i></button>
                                                                <ul role="menu" class="dropdown-menu pull-right">
                                                                    <li><a href="javascript:void(0);" class="filter-cancel">重置</a></li>
                                                                </ul>
                                                            </div>
                                                        </th>
                                                    </tr>
                                                    </thead>
                                                    <tbody></tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--结束-->
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        var id = '<?php echo $id?>';
        var startTime = '<?php echo $startTime?>';
        var endTime = '<?php echo $endTime?>';
        datatable_init({
            src: $("#datatable"),
            sAjaxSource: "<?php echo getUrl('statistics/operate/getOrderList?id='.$id);?>",
            aoColumnDefs : [{
                'bSortable' : false,
                'aTargets' : [0,1,2,3,4,7,8,9]
            }]
        });
        datatable_init({
            src: $("#datatable_after"),
            sAjaxSource: "<?php echo getUrl('statistics/operate/getAfterOrderList?id='.$id);?>",
            aoColumnDefs : [{
                'bSortable' : false,
                'aTargets' : [0,1,2,3,4,7,8]
            }]
        });

        $('[dp]').not("[noinit]").datepicker({
            changeMonth: true,
            autoclose: true,
            format: "yyyy-mm-dd",
            language: 'zh-CN',
            startDate: "<?php echo $startTime?>", endDate : "<?php echo $endTime?>"
        });
        $(".export").on('click',function () {
            window.location.href="<?php echo getUrl('statistics/operate/saleExport?exportType=2&id='.$id.'&take_time_from='.$startTime.'&take_time_to='.$endTime)?>";
        })
    });
</script>
</body>
</html>